﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Collections;

namespace Consultator
{
    public partial class Form1 : Form
    {
        private Connection sqlCon = new Connection();
        private ArrayList RequestList = new ArrayList();
        private ArrayList YesList = new ArrayList();
        private ArrayList NoList = new ArrayList();
        private String question;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            FillTextFields(1);
            
        }

        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            question = textBox1.Text;
        }
        private void FillTextFields(int id)
        {
            sqlCon.GetAllInfo(id, RequestList, YesList, NoList);
            listBox1.Items.Add(RequestList[0].ToString());
            listBox1.Items.Add(YesList[0].ToString());
            listBox1.Items.Add(NoList[0].ToString()); 
            
            
            
        }

        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
          //  listBox1.Items.Add(listBox1.SelectedIndex);
            if (listBox1.SelectedIndex.Equals(1))
            {
                
                String line = YesList[0].ToString();
                String word = "";
                for (int i = 0; i < line.Length; i++)
                {
                    if (line[i] != ';')
                    {
                        word += line[i];
                    }
                    if (word != "" && line[i].Equals(';') || i.Equals(line.Length-1))
                    {
                        listBox1.Items.Add(word);
                        word = "";
                    }
                }
            }
        }
    }
}
